(function($) {
  $.fn.lockTopic = function() {
    return this.each(function() {
      if (this.tagName.toLowerCase() === 'table') {
        //这才开始处理
        var rows = this.rows;
        if (rows.length > 1) {
          //自身宽度设置
          if ($(this).attr('locked') != 'true') {
            for (var i = rows[0].cells.length - 1; i >= 0; i--) {
              if (rows[0].cells[i].width != rows[0].cells[i].clientWidth) {
                rows[0].cells[i].width = rows[0].cells[i].clientWidth;
              }
            }
            var headerHtml = $(this.rows[0]).html();
            var newRow = this.insertRow(0);
            $(newRow).html(headerHtml);
            $(newRow).css('position', 'absolute');
            $(newRow).css('background-color', '#fff');
            $(this).attr('locked', 'true');
          } else {
            for (var i = rows[0].cells.length - 1; i >= 0; i--) {
              if (rows[0].cells[i].width != rows[1].cells[i].clientWidth) {
                rows[0].cells[i].width = rows[1].cells[i].clientWidth;
              }
            }
          }
        }
      }
    });
  }
})(jQuery);